import { UnitGateComponent } from "../../../../Model/Server/Demo/Map/Unit/UnitGateComponent";
import { ActorMessageSenderComponent } from "../../../../Model/Server/Module/Actor/ActorMessageSenderComponent";
import { ActorLocationSenderComponent } from "../../../../Model/Server/Module/ActorLocation/ActorLocationSenderComponent";
import { IActorMessage, IActorRequest, IActorResponse } from "../../../../Model/Share/Module/Actor/IActorMessage";
import { IActorLocationMessage, IActorLocationRequest, IActorLocationResponse } from "../../../../Model/Share/Module/ActorLocation/IActorLocationMessage";
import { Unit } from "../../../../Model/Share/Module/Unit/Unit";

export class MessageHelper {

    public static Broadcast(unit: Unit, message: IActorMessage) {

    }

    public static SendToClient(unit: Unit, message: IActorMessage) {
        this.SendActor(unit.GetComponent<UnitGateComponent>(UnitGateComponent).GateSessionActorId, message);
    }

    public static SendToLocationActor(id: number, message: IActorLocationMessage) {
        ActorLocationSenderComponent.Instance.Send(id, message);
    }

    public static SendActor(actorId: number, message: IActorMessage) {
        ActorMessageSenderComponent.Instance.Send(actorId, message);
    }

    public static async CallActor(actorId: number, message: IActorRequest): Promise<IActorResponse> {
        return await ActorMessageSenderComponent.Instance.Call(actorId, message);
    }

    public static async CallLocationActor(id: number, message: IActorLocationRequest): Promise<IActorLocationResponse> {
        return await ActorLocationSenderComponent.Instance.Call(id, message);
    }

}